$('#orderTotal').text("订单（10笔)");
$('#yearTotal').text("20");
$('#yearProportion').text("2");
$("#yearStyle").css("width", 100);
$('#monthTotal').text("20");
$('#monthProportion').text("2");
$("#monthStyle").css("width", 100);
$('#weekTotal').text("20");
$('#weekProportion').text("2");
$("#weekStyle").css("width", 100);
$('#dayTotal').text("20");
$('#dayProportion').text("2");
$("#dayStyle").css("width", 100);

//----------------------------------------百度echarts数据--------------------------------------------------------------


//订单chart数据
var orderLineChart = echarts.init(document.getElementById("order-line-chart"));
getOrderLineChartData(4);
$(window).resize(orderLineChart.resize);


function orderUpdateDate(that, code) {
    getOrderLineChartData(code);

    $('#dayOrderDate').removeClass("active");
    $('#monthOrderDate').removeClass("active");
    $('#yearOrderDate').removeClass("active");
    $(that).addClass("active");
}

function getOrderLineChartData(code) {
    // $.ajax({
    //     url : "/main/orderLineChart",
    //     type : "get",
    //     data : {code:code},
    //     success : function(res) {
    //         if (res.code==0) {
    //             console.log(res);
    var res = {
        data: {
            text: '订单情况',
            suffix: '月',
            transverseData: ["1", "2"],
            orderData: ['22', '33'],
            completeOrderData: ['44', '55']
        }
    };
    $.getJSON("/js/json/orderChart.json", function (data) {
        console.log("data前:", data);
        data.title.text = res.data.text;
        data.xAxis[0].axisLabel.formatter = "{value}" + res.data.suffix;
        data.xAxis[0].data = res.data.transverseData;
        data.series[0].data = res.data.orderData;
        data.series[1].data = res.data.completeOrderData;
        orderLineChart.setOption(data, true);
    });
    //         }
    //     }
    // });
}


//用户chart数据
var userChart = echarts.init(document.getElementById("user-chart"));
getUserChartData(4);
$(window).resize(userChart.resize);

function userUpdateDate(that, code) {
    getUserChartData(code);

    $('#dayUserDate').removeClass("active");
    $('#monthUserDate').removeClass("active");
    $('#yearUserDate').removeClass("active");
    $(that).addClass("active");
}

function getUserChartData(code) {
    var res = {
        data: {
            text: '会员情况',
            suffix: '月',
            transverseData: ["1", "2"],
            clientData: ['22', '33'],
            serverData: ['44', '55'],
            stationmasterData: ['32', '51']
        }
    };
    $.getJSON("/js/json/userChart.json", function (data) {
        data.title.text = res.data.text;
        data.xAxis[0].axisLabel.formatter = "{value}" + res.data.suffix;
        data.xAxis[0].data = res.data.transverseData;
        data.series[0].data = res.data.clientData;
        data.series[1].data = res.data.serverData;
        data.series[2].data = res.data.stationmasterData;
        // console.log("data后:", data);
        userChart.setOption(data, true);
    });
}


//发票chart数据
var invoiceChart = echarts.init(document.getElementById("invoice-chart"));
getInvoiceChartData(4, -1, -1);
$(window).resize(invoiceChart.resize);

function invoiceUpdateDate(that, code) {
    getInvoiceChartData(code, -1, -1);
    $('#dayInvoiceDate').removeClass("active");
    $('#monthInvoiceDate').removeClass("active");
    $('#yearInvoiceDate').removeClass("active");
    $(that).addClass("active");
}

function getInvoiceChartData(code, year, month) {
    var res = {
        data: {
            text: '发票情况',
            suffix: '月',
            transverseData: ["1", "2"],
            invoiceData: ['22', '33'],
            completeOrderData: ['44', '55']
        }
    };
    $.getJSON("/js/json/invoiceChart.json", function (data) {
        // console.log("发票data前:", data);
        data.title.text = res.data.text;
        data.xAxis[0].axisLabel.formatter = "{value}" + res.data.suffix;
        data.xAxis[0].data = res.data.transverseData;
        data.series[0].data = res.data.invoiceData;
        data.series[1].data = res.data.completeInvoiceData;
        // console.log("发票data后:", data);
        invoiceChart.setOption(data, true);
    });
}

function isPublicCourse() {
    var year = $("#year").val();
    var month = $("#month").val();
    console.log("year", year, month);
    getInvoiceChartData(4, year, month)
}






